using System.Windows;

namespace MinoChat.Ui.Controls;

/// <summary>
/// 简单的自定义按钮控件，支持圆角和悬停/按下状态的背景色
/// </summary>
public class Button : System.Windows.Controls.Button
{
    static Button()
    {
        DefaultStyleKeyProperty.OverrideMetadata(typeof(Button),
            new FrameworkPropertyMetadata(typeof(Button)));
    }

    #region 依赖属性

    // 背景边框的圆角半径
    public static readonly DependencyProperty CornerRadiusProperty =
        DependencyProperty.Register(
            nameof(CornerRadius),
            typeof(CornerRadius),
            typeof(Button),
            new PropertyMetadata(new CornerRadius(6)));

    public CornerRadius CornerRadius
    {
        get => (CornerRadius)GetValue(CornerRadiusProperty);
        set => SetValue(CornerRadiusProperty, value);
    }

    // 鼠标悬停时的背景色
    public static readonly DependencyProperty HoverBackgroundProperty =
        DependencyProperty.Register(
            nameof(HoverBackground),
            typeof(System.Windows.Media.Brush),
            typeof(Button),
            new PropertyMetadata(null));

    public System.Windows.Media.Brush HoverBackground
    {
        get => (System.Windows.Media.Brush)GetValue(HoverBackgroundProperty);
        set => SetValue(HoverBackgroundProperty, value);
    }

    // 按下时的背景色
    public static readonly DependencyProperty PressedBackgroundProperty =
        DependencyProperty.Register(
            nameof(PressedBackground),
            typeof(System.Windows.Media.Brush),
            typeof(Button),
            new PropertyMetadata(null));

    public System.Windows.Media.Brush PressedBackground
    {
        get => (System.Windows.Media.Brush)GetValue(PressedBackgroundProperty);
        set => SetValue(PressedBackgroundProperty, value);
    }

    #endregion
}
